package spikes_activity

import (
	
	"github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
    "github.com/flipped-aurora/gin-vue-admin/server/model/spikes_activity"
    spikes_activityReq "github.com/flipped-aurora/gin-vue-admin/server/model/spikes_activity/request"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type SpikesActivitiesApi struct {}



// CreateSpikesActivities 创建spikesActivities表
// @Tags SpikesActivities
// @Summary 创建spikesActivities表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body spikes_activity.SpikesActivities true "创建spikesActivities表"
// @Success 200 {object} response.Response{msg=string} "创建成功"
// @Router /spikesActivities/createSpikesActivities [post]
func (spikesActivitiesApi *SpikesActivitiesApi) CreateSpikesActivities(c *gin.Context) {
	var spikesActivities spikes_activity.SpikesActivities
	err := c.ShouldBindJSON(&spikesActivities)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = spikesActivitiesService.CreateSpikesActivities(&spikesActivities)
	if err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败:" + err.Error(), c)
		return
	}
    response.OkWithMessage("创建成功", c)
}

// DeleteSpikesActivities 删除spikesActivities表
// @Tags SpikesActivities
// @Summary 删除spikesActivities表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body spikes_activity.SpikesActivities true "删除spikesActivities表"
// @Success 200 {object} response.Response{msg=string} "删除成功"
// @Router /spikesActivities/deleteSpikesActivities [delete]
func (spikesActivitiesApi *SpikesActivitiesApi) DeleteSpikesActivities(c *gin.Context) {
	ID := c.Query("ID")
	err := spikesActivitiesService.DeleteSpikesActivities(ID)
	if err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("删除成功", c)
}

// DeleteSpikesActivitiesByIds 批量删除spikesActivities表
// @Tags SpikesActivities
// @Summary 批量删除spikesActivities表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
// @Router /spikesActivities/deleteSpikesActivitiesByIds [delete]
func (spikesActivitiesApi *SpikesActivitiesApi) DeleteSpikesActivitiesByIds(c *gin.Context) {
	IDs := c.QueryArray("IDs[]")
	err := spikesActivitiesService.DeleteSpikesActivitiesByIds(IDs)
	if err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("批量删除成功", c)
}

// UpdateSpikesActivities 更新spikesActivities表
// @Tags SpikesActivities
// @Summary 更新spikesActivities表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body spikes_activity.SpikesActivities true "更新spikesActivities表"
// @Success 200 {object} response.Response{msg=string} "更新成功"
// @Router /spikesActivities/updateSpikesActivities [put]
func (spikesActivitiesApi *SpikesActivitiesApi) UpdateSpikesActivities(c *gin.Context) {
	var spikesActivities spikes_activity.SpikesActivities
	err := c.ShouldBindJSON(&spikesActivities)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = spikesActivitiesService.UpdateSpikesActivities(spikesActivities)
	if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("更新成功", c)
}

// FindSpikesActivities 用id查询spikesActivities表
// @Tags SpikesActivities
// @Summary 用id查询spikesActivities表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query spikes_activity.SpikesActivities true "用id查询spikesActivities表"
// @Success 200 {object} response.Response{data=spikes_activity.SpikesActivities,msg=string} "查询成功"
// @Router /spikesActivities/findSpikesActivities [get]
func (spikesActivitiesApi *SpikesActivitiesApi) FindSpikesActivities(c *gin.Context) {
	ID := c.Query("ID")
	respikesActivities, err := spikesActivitiesService.GetSpikesActivities(ID)
	if err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败:" + err.Error(), c)
		return
	}
	response.OkWithData(respikesActivities, c)
}
// GetSpikesActivitiesList 分页获取spikesActivities表列表
// @Tags SpikesActivities
// @Summary 分页获取spikesActivities表列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query spikes_activityReq.SpikesActivitiesSearch true "分页获取spikesActivities表列表"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
// @Router /spikesActivities/getSpikesActivitiesList [get]
func (spikesActivitiesApi *SpikesActivitiesApi) GetSpikesActivitiesList(c *gin.Context) {
	var pageInfo spikes_activityReq.SpikesActivitiesSearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	list, total, err := spikesActivitiesService.GetSpikesActivitiesInfoList(pageInfo)
	if err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败:" + err.Error(), c)
        return
    }
    response.OkWithDetailed(response.PageResult{
        List:     list,
        Total:    total,
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
}

// GetSpikesActivitiesPublic 不需要鉴权的spikesActivities表接口
// @Tags SpikesActivities
// @Summary 不需要鉴权的spikesActivities表接口
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
// @Router /spikesActivities/getSpikesActivitiesPublic [get]
func (spikesActivitiesApi *SpikesActivitiesApi) GetSpikesActivitiesPublic(c *gin.Context) {
    // 此接口不需要鉴权
    // 示例为返回了一个固定的消息接口，一般本接口用于C端服务，需要自己实现业务逻辑
    spikesActivitiesService.GetSpikesActivitiesPublic()
    response.OkWithDetailed(gin.H{
       "info": "不需要鉴权的spikesActivities表接口信息",
    }, "获取成功", c)
}
